/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Servidor.Controlador;

import Servidor.Modelo.Games.GameList;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.net.Socket;

/**
 *
 * @author isabel
 */
public class FinishGame extends Thread implements OcaTask {

    private Socket socket;
    private BufferedReader read;
    private PrintWriter write;
     int idGame;

    public FinishGame(Socket socket, BufferedReader read, PrintWriter write) {
        this.write = write;
        this.socket = socket;
        this.read = read;
    }

    @Override
    public void executeTask() {
        this.start();
    }

    
    @Override
    public void run() {
        
          String idGameString = null;

        try {
            idGameString = read.readLine();
        } catch (IOException ex) {
            System.out.println("No se pudo leer la id partida para Terminarla");
        }

        try {
            idGame = Integer.parseInt(idGameString);
        } catch (NumberFormatException ex) {
            System.out.println("La id partida para unirse no es valida");
        }
        
        GameList.getInstance().getGame(idGame).finish_game();
      
    }
}
        
        
        
        